/**
 * Copyright 2010 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

addScriptToInject(function() {

chrome_comp.CompDetect.declareDetector(

'document_execcommand',

chrome_comp.CompDetect.ScanDomBaseDetector,

function constructor(rootNode) {
  var This = this;
  this.execCommandHookHandler_ = function(result, originalArguments, callStack) {
    var commandList = {
      'backColor': '',
      'bold': '',
      'createLink': '',
      'delete': '',
      'fontSize': '',
      'foreColor': '',
      'formatBlock': '',
      'indent': '',
      'insertHorizontalRule': '',
      'insertImage': '',
      'insertOrderedList': '',
      'insertUnorderedList': '',
      'insertParagraph': '',
      'italic': '',
      'justifyCenter': '',
      'justifyLeft': '',
      'justifyRight': '',
      'justifyFull': '',
      'outdent': '',
      'removeFormat': '',
      'selectAll': '',
      'strikeThrough': '',
      'subscript': '',
      'superscript': '',
      'underline': '',
      'unlink': ''
    };
    if (originalArguments[0] in commandList)
      return;
    This.addProblem('BX9054', { nodes: [this], needsStack: true });
  };
},

function checkNode(node, context) {
  if (Node.ELEMENT_NODE != node.nodeType || node.tagName != 'IFRAME' ||
      context.isDisplayNone())
    return;

  chrome_comp.CompDetect.registerExistingMethodHook(
      node.contentWindow.Document.prototype,
      'execCommand',
      this.execCommandHookHandler_);
},

function setUp() {

},

function cleanUp() {

}
); // declareDetector

});
